<?php
	header('Content-type: application/json');
	$definition = "";
	$url = "";
	require_once 'application/dataAccess.php';
	$da = new dataAccess();
	$term = $_GET["term"];
	$found = "false";
	if (strlen($term) > 0)
	{
		$result = $da->searchTerm($term);		
		while($row = mysql_fetch_array($result))
		{	
			$definition = str_replace("\"", "\\\"", $row["definition"]); 							
			$url = str_replace("\"", "\\\"", $row["url"]);
			$found = "true";			
		}		
	}
	$data = '{"term": "'. $term .'", "definition": "'. $definition .'", "url": "'. $url .'", "found":' . $found . '}';	
	echo  $data;
?>